#!/bin/bash

# echo -ne "\0\0\x4\0\0\0\0\0" > /dev/hidg0					# 按下 按键a (连续输出 a)
# echo -ne "\0\0\x0\0\0\0\0\0" > /dev/hidg0					# 松开 按键 (停止连续输出 a)
# echo -ne "\x2\0\x4\0\0\0\0\0" > /dev/hidg0				# 按下 按键A (连续输出 A)
# echo -ne "\0\0\x0\0\0\0\0\0" > /dev/hidg0					# 松开 按键 (停止连续输出 A)
# echo -ne "\0\0\x4\0\0\0\0\0\0\0\0\0\0\0\0\0" > /dev/hidg0	# 按下 按键a 并松开 按键 (输出一个 a)

# root@rpi:/home/pi# echo "l s enter" | ./hid-gadget-test /dev/hidg0 keyboard
# root@rpi:/home/pi# ls
# hid-gadget-test.c  hid.sh  hid-gadget-test
# root@rpi:/home/pi#

# Test if is Root
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi

for run in {1..10}
do
	echo -ne "\x00\x00\x00\x17\x00\x00\x00\x00" > /dev/hidg0
	echo -ne "\x00\x00\x00\x00\x00\x00\x00\x00"  > /dev/hidg0
done
